package com.bnzj.cloud.business.core.persistence.repository;

import com.bnzj.cloud.business.core.persistence.entity.GroupCourse;
import com.bnzj.core.persistence.repository.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface GroupCourseRepository extends BaseRepository<GroupCourse, Long> {

    @Modifying
    @Query("delete from #{#entityName} where group_id = (?1)")
    void deleteByGroupId(String groupId);

    /**
     * 添加
     * @param groupCourse
     */
    @Modifying
    @Query(value = "insert into bnz_group_course (group_id, course_id, creator, create_time, creator_name) "
            + "values (?#{[0].groupId}, ?#{[0].courseId}, ?#{[0].creator}, ?#{[0].createTime}, ?#{[0].creatorName})", nativeQuery = true)
    void newSave(GroupCourse groupCourse);

}
